package pl.edu.agh.logview;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class CustomDialog extends JDialog implements ActionListener{

	private static final long serialVersionUID = 1L;
    private JButton okButton = null;
    private boolean answer = false;
    public boolean getAnswer() { return answer; }

    public CustomDialog(JFrame frame, boolean modal, String myMessage) {
        super(frame, modal);
        setSize(new Dimension(200,200));
        getContentPane().setLayout(new BorderLayout());
                
        JTextArea textArea = new JTextArea(myMessage);
		textArea.setLineWrap(true);
        JScrollPane scroll= new JScrollPane(textArea);
        scroll.setPreferredSize(new Dimension(200,200));

        okButton = new JButton("OK");
        okButton.addActionListener(this);
        
        add(new JLabel("Treść wiadomości"),BorderLayout.PAGE_START);
        add(scroll,BorderLayout.CENTER);
        add(okButton,BorderLayout.PAGE_END); 
        
        pack();
        setLocationRelativeTo(frame);
        setVisible(true);
    }

    public void actionPerformed(ActionEvent e) {
        if(okButton == e.getSource()) {
            setVisible(false);
        }
    }
}
